﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.woodsoft.core;
using EQ1.Elements;
using com.woodsoft.core.Files;
using EQ1.Objects;

namespace EQ1.Controls {
  public class HtmlComponent : Control , IUIElement<HtmlComponent> {
    public HtmlComponent ( UIDocument doc , string name )
      : base( doc , name ) {
    }
    public HtmlComponent ( UIDocument doc )
      : this( doc , "HtmlComponent" ) {
    }

    #region IUIElement<HtmlComponent> Members

    public void Validate ( HtmlComponent val , string name ) {
      UIClass par = ( UIClass ) this.ParentNode;

      if( val.LocalName != name ) {
        HtmlComponent el = new HtmlComponent( ( UIDocument ) val.OwnerDocument , name );
        el.Copy( val );
        val = el;
      }

      if( par.GetElement( name ) != null )
        par.RemoveElement( name );

      par.AppendChild( val );
    }
    public void Copy ( HtmlComponent val ) {
      if( val.StartUri != null )
        this.StartUri = val.StartUri;
    }

    #endregion

    public string StartUri {
      get {
        return this.GetElement( "StartUri" ).InnerText;
      }
      set {
        this.Validate( "StartUri" , value );
      }
    }
  }
}
